package models

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Username string `gorm:"type:varchar(30)" json:"username"`
	Password string `gorm:"type:varchar(255)" json:"password"`
}

type Prod struct {
	gorm.Model
	Name     string `gorm:"type:varchar(30)" json:"name"`
	Content  string `gorm:"type:varchar(30)" json:"content"`
	Num      int    `gorm:"type:int" json:"num"`
	UserID   int    `gorm:"type:int" json:"user_id"`
	User     User   `gorm:"foreignKey:UserID" json:"user"`
	TypesID  int    `gorm:"type:int" json:"types-id"`
	Types    Types  `gorm:"foreignKey:TypesID" json:"types"`
	XiaCount int    `gorm:"type:int" json:"xia"`
}

type Types struct {
	gorm.Model
	Name string `gorm:"type:varchar(30)" json:"name"`
}

type Xia struct {
	gorm.Model
	UserID int  `gorm:"type:int" json:"user_id"`
	User   User `gorm:"foreignKey:UserID" json:"user"`
	ProdID int  `gorm:"type:int" json:"prod_id"`
	Prod   Prod `gorm:"foreignKey:ProdID" json:"prod"`
}
